package com.tian.system.controller;

import java.util.List;

import com.tian.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tian.system.domain.Role;
import com.tian.system.service.IRoleService;

/**
 * 角色表 信息操作处理
 *
 * @author zcx
 * @date 2019-12-09 15:32:00
 */
@Controller
@RequestMapping("/system/role")
public class RoleController {
    private String prefix = "system/role";

	@Autowired
	private IRoleService roleService;

	/**
	 * 查询角色表列表
	 */
	@PostMapping("/list")
	@ResponseBody
	public String list(Role role){
		AjaxResult ajaxResult = new AjaxResult();
        List<Role> list = roleService.selectRoleList(role);
		return ajaxResult.success(list);
	}

	/**
	 * 新增保存角色表
	 */
	@PostMapping("/add")
	@ResponseBody
	public String addSave(Role role){
		AjaxResult ajaxResult = new AjaxResult();
		return ajaxResult.success(roleService.insertRole(role));
	}

	/**
	 * 修改保存角色表
	 */
	@PostMapping("/edit")
	@ResponseBody
	public String editSave(Role role){
		AjaxResult ajaxResult = new AjaxResult();
		return ajaxResult.success(roleService.updateRole(role));
	}

	/**
	 * 删除角色表
	 */
	@PostMapping( "/remove")
	@ResponseBody
	public String remove(String ids){
		AjaxResult ajaxResult = new AjaxResult();
		return ajaxResult.success(roleService.deleteRoleByIds(ids));
	}

}
